put "cleanup" && quote & thisStack & quote & comma && quote & sourceFile & quote into theMessage
send theMessage to stack newStack
end mouseUp
on cleanup useStack, sourceFile
start using stack useStack
put resList (sourceFile) into temp
repeat with i = 1 to number of lines in temp
if line i of temp contains "STR#" then
put item 3 of line i of temp into resourceID
copyRes sourceFile, short name of this stack, "STR#", resourceID
addDisc listDiscContents (resourceID)
killRes "STR#", resourceID
end if
end repeat
stop using stack useStack
sort cards of this stack by bg fld discTitle
set script of me to restOfScript (script of me, "***")
doMenu "Compact Stack"
show all cards
end cleanup
-- return delimited list of a CD's title and tracks
function listDiscContents resourceID
repeat with i = 1 to 999
put getStr (resourceID, i) into tempString
if tempString is empty then exit repeat
put tempString & return after theString
end repeat
return theString
end listDiscContents
on addDisc discInfo
if bg fld 1 is not empty then doMenu "New Card"
put line 1 of discInfo into bg fld discTitle
put line 2 to 999 of discInfo into bg fld trackTitles
end addDisc
on firstCard trackScript
createBgField1
createBgField2
createBgButton1
createBgButton2
set script of bg fld "discTitle" to partOfScript(script of me, "~~~")
set script of bg fld "trackTitles" to partOfScript(script of me, "@@@")
set script of bg btn "Go Prev" to partOfScript(script of me, "<<<")
set script of bg btn "Go Next" to partOfScript(script of me, ">>>")
end firstCard
on createBgField theTop, theLeft, theBottom, theRight
choose field tool
doMenu "Background"
drag from theLeft, theTop to theRight, theBottom with commandKey
doMenu "Background"
choose browse tool
end createBgField
on createBgField1
createBgField 0, 0, 15, 256
set name of bg fld 1 to "discTitle"
set style of bg fld 1 to rectangle
set lockText of bg fld 1 to true
set textSize of bg fld 1 to 9
set textFont of bg fld 1 to Genvea
set textStyle of bg fld 1 to bold
set textAlign of bg fld 1 to center
end createBgField1
on createBgField2
createBgField 17, 0, 235, 256
set name of bg fld 2 to "trackTitles"
set style of bg fld 2 to scrolling
set lockText of bg fld 2 to true
set textSize of bg fld 2 to 9
set textFont of bg fld 2 to Genvea
set textStyle of bg fld 2 to bold
end createBgField2
on createBgButton theTop, theLeft, theBottom, theRight
choose button tool
doMenu "Background"
drag from theLeft, theTop to theRight, theBottom with commandKey
doMenu "Background"
choose browse tool
end createBgButton
on createBgButton1
createBgButton 235, 0, 256, 30
set name of bg btn 1 to "Go Prev"
set icon of bg btn 1 to "Prev Arrow"
end createBgButton1
on createBgButton2
createBgButton 235, 226, 256, 256
set name of bg btn 2 to "Go Next"
set icon of bg btn 2 to "Next Arrow"
end createBgButton2
-- Return text of theScript located between two occurences of
-- theToken & return.
function partOfScript theScript, theToken
put restOfScript (theScript, theToken) into theScript
delete char offset (theToken & return, theScript) to 9999 of theScript
delete last line of theScript
return theScript
end partOfScript
-- Return text of theScript minus all text before theToken & return.
function restOfScript theScript, theToken
delete char 1 to offset (theToken & return, theScript) of theScript
delete first line of theScript
return theScript
end restOfScript
-- Permanent script of bg btn "Go Prev of the new stack is below.
-- The partOfScript() routine will cut this script here ---> <<<
on mouseUp
visual effect wipe right
do (short name of me)
end mouseUp
-- The partOfScript() routine will cut this script here ---> <<<
-- Permanent script of bg btn "Go Next" of the new stack is below.
-- The partOfScript() routine will cut this script here ---> >>>
on mouseUp
visual effect wipe left
do (short name of me)
end mouseUp
-- The partOfScript() routine will cut this script here ---> >>>
-- Permanent script of bg fld "discTitle" of the new stack is below.
-- The partOfScript() routine will cut this script here ---> ~~~
on mouseUp
edit script of this stack
end mouseUp
-- The partOfScript() routine will cut this script here ---> ~~~
-- Permanent script of bg fld "trackTitles" of the new stack is below.
-- The partOfScript() routine will cut this script here ---> @@@
on mouseUp
select the clickLine
if the selection is empty then
beep
else
playThis word 2 of the clickLine && bg fld discTitle
wait 1 second
select after last char of me
end if
end mouseUp
-- The partOfScript() routine will cut this script here ---> @@@
-- Permanent script of the new stack is below.
-- The restOfScript() routine will cut this script here ---> ***
-- Stack created by Claussoft International's "CD Programs Reader"
on playThis tuneInfo
if tuneInfo is empty then exit playThis
put word 1 of tuneInfo into trackNumber
put word 2 to 99 of tuneInfo into discTitle
if getCD (discTitle) then CDPlayTrack (trackNumber)
end playThis
function getCD discTitle
global xxxCDRefNum
CDOpen
put CDDiscTitle() into currTitle
if currTitle = discTitle then return true -- Correct CD found
-- No CD found
if xxxCDRefNum is empty or xxxCDRefNum = 0 then
answer "Please insert the Compact Disc:" & return & " " & discTitle & "…" with "Cancel" or "OK"
if it = "Cancel" then
return false
else
mountCD
return getCD(discTitle)
end if
end if
-- Incorrect CD found
if currTitle is empty then put "Untitled" into currTitle
answer "The current Compact Disc is" && quote & currTitle & "." & quote & return & "It can be renamed to" && quote & discTitle & quote && "or ejected." with "Cancel" or "Rename CD" or "Eject CD"
if it = "Cancel" then return false
if it = "Rename CD" then
renameCD currTitle, discTitle
else
CDEject
end if
return getCD(discTitle)
end getCD
on mountCD
repeat until CDStatus() >= 0
CDOpen
end repeat
end mountCD
on renameCD oldTitle, newTitle
answer "Are you sure that you want to rename the CD:" && quote & oldTitle & quote && "to" && quote & newTitle & quote & "?" with "Cancel" or "Rename CD"